package com.artqiyi.dollmachine.views.widget.dialog;

import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.artqiyi.dollmachine.R;


/**
 * 充值dialog
 */
public class RxDialogReadyGo extends RxDialog {

    private ImageView mImageReadyGo;

    private AnimationDrawable animationDrawable;

    public RxDialogReadyGo(Context context, int themeResId) {
        super(context, themeResId);
        mContext = context;
        initView();
    }

    public RxDialogReadyGo(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
        mContext = context;
        initView();
    }

    public RxDialogReadyGo(Context context) {
        super(context);
        mContext = context;
        initView();
    }

    public RxDialogReadyGo(Activity context) {
        super(context);
        mContext = context;
        initView();
    }

    public RxDialogReadyGo(Context context, float alpha, int gravity) {
        super(context, alpha, gravity);
        mContext = context;
        initView();
    }

    private void initView() {
        View dialog_view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_ready_go, null);
        mImageReadyGo = (ImageView) dialog_view.findViewById(R.id.imageReadyGo);
        setContentView(dialog_view);
        animationDrawable = (AnimationDrawable) mImageReadyGo.getDrawable();
        animationDrawable.start();
        mImageReadyGo.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (mOnAnimCompleteLister != null) {
                    mOnAnimCompleteLister.onComplete();
                }
            }
        }, 3000);
        setCanceledOnTouchOutside(false);
    }

    private OnAnimCompleteLister mOnAnimCompleteLister;
    public void setOnAnimCompleteLister(OnAnimCompleteLister onAnimCompleteLister) {
        mOnAnimCompleteLister = onAnimCompleteLister;
    }
    public interface OnAnimCompleteLister {
        void onComplete();
    }
}
